package itbour.onetouchshow.fragment.home_v1_3;

import android.util.Log;

import com.lsjr.callback.EncryBeanCallBack;
import com.lsjr.utils.HttpUtils;

import java.util.HashMap;

import itbour.onetouchshow.base.mvp.BasePresenterImpl;
import itbour.onetouchshow.constants.AppConfig;
import itbour.onetouchshow.utils.DeviceUtil;
import itbour.onetouchshow.utils.L_;
import itbour.onetouchshow.utils.UIUtils;

/**
 * Created by Yang on 2018/2/27.
 */

public class V_1_3HomePresenter extends BasePresenterImpl<V_1_3HomeContract.View> implements V_1_3HomeContract.Presenter {

    public V_1_3HomePresenter(V_1_3HomeContract.View view) {
        mvpView = view;
    }


    public void getHomepageInfo() {
        HashMap<String, Object> requestHashMap = new HashMap<>();
        requestHashMap.put("device", "610");
        String appVersionName = DeviceUtil.getAppVersionName(UIUtils.getContext());
        requestHashMap.put("appVer", appVersionName);
        Log.e("tag", requestHashMap.toString());
        HttpUtils.getInstance().executeGet(AppConfig.GETAPPHOMEPAGEINFO_V1_3, requestHashMap, new EncryBeanCallBack() {
            @Override
            protected void onXError(String exception) {
                L_.i("response  homepageInfo===" + exception);
                if (mvpView != null) {
                    mvpView.loadFaild(exception);
                }
            }

            @Override
            protected void onSuccess(String response) {
                L_.i("response  homepageInfo===" + response);
                if (mvpView != null) {
                    mvpView.loadSucceed(response);
                }
            }
        });
    }

    public void getFreedomCreateConfigInfo() {
        HashMap<String, Object> requestHashMap = new HashMap<>();
        requestHashMap.put("device", "620");
        requestHashMap.put("userId", "65");
        String appVersionName = DeviceUtil.getAppVersionName(UIUtils.getContext());
        requestHashMap.put("appVer", appVersionName);
        HttpUtils.getInstance().executeGet(AppConfig.GET_CUSTOM_VIDEO_CONFIGURE, requestHashMap, new EncryBeanCallBack() {
            @Override
            protected void onXError(String exception) {
                L_.i("response  CreatConfigInfo===" + exception);
                if (mvpView != null) {
                    mvpView.getConfigFail(exception);
                }
            }

            @Override
            protected void onSuccess(String response) {
                L_.i("response  CreatConfigInfo===" + response);
                if (mvpView != null) {
                    mvpView.getConfigSuccess(response);
                }
            }
        });
    }

}

